package result

import "gitee.com/xxhsjp/x-core/enums"

type StdResp[T any] struct {
	Code string `json:"code"`
	Msg  string `json:"msg,omitempty"`
	Data T      `json:"data,omitempty"`
}

func Success[T any](data T) *StdResp[T] {
	return &StdResp[T]{Code: enums.Success.Code, Data: data}
}

func Failure(code string, msg string) *StdResp[string] {
	return &StdResp[string]{Code: code, Msg: msg}
}
